package file;

import java.io.File;
import java.util.Date;

public class FileDemo {
    public static void main(String[] args) {
        File file = new File("./demo.txt"); //  .\\demo.txt
        System.out.println(file);  //C:\Users\JSD\IdeaProjects\JavaSE2107\\demo.txt  绝对路径

        long length = file.length();
        System.out.println(length);

        boolean r = file.canRead();
        boolean w = file.canWrite();
        System.out.println("可读:"+r);
        System.out.println("可写:"+w);

        long t = file.lastModified();
        System.out.println("最后编辑时间:"+t);
        long y = t/1000/60/60/24/365 + 1970;
        System.out.println(y);
        System.out.println(new Date(t));

    }
}
